//
//  LzwEatTableViewCell.m
//  NewHalfsugar
//
//  Created by 刘志武 on 16/1/2.
//  Copyright © 2016年 刘志武. All rights reserved.
//

#import "LzwEatTableViewCell.h"
#import "LzwBaseImageView.h"
#import "LzwBaseLable.h"
#import "UIImageView+WebCache.h"

@interface LzwEatTableViewCell ()

@property (nonatomic, retain) LzwBaseImageView *myImageEat;
@property (nonatomic, retain) LzwBaseImageView *myImageEat1;

@property (nonatomic, retain) LzwBaseLable *myLableEat;
@property (nonatomic, retain) LzwBaseLable *myLableEat1;


@end

@implementation LzwEatTableViewCell

-(void)dealloc{
    
    [_myImageEat release];
    [_myImageEat1 release];
    [_myLableEat release];
    [_myLableEat1 release];
    [super dealloc];
    
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        [self creatEat];
    }
    return self;
}

- (void)creatEat{
    
    //图片
    self.myImageEat = [[LzwBaseImageView alloc]initWithFrame:CGRectMake(3 * WIDTH, 3 * WIDTH, 370 * WIDTH, 180 * WIDTH)];
    self.myImageEat.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.myImageEat];
    
    //喜爱图片
    self.myImageEat1 = [[LzwBaseImageView alloc]initWithFrame:CGRectMake((375 - 20) / 2 - 70 * WIDTH, 230 * WIDTH, 20 * WIDTH, 20 * WIDTH)];
    self.myImageEat1.image = [UIImage imageNamed:@"love.png"];
    [self.contentView addSubview:self.myImageEat1];
    
    //描述
    self.myLableEat = [[LzwBaseLable alloc]initWithFrame:CGRectMake(2 * WIDTH, 185 * WIDTH, 369 * WIDTH, 45 * WIDTH)];
    self.myLableEat.textColor = [UIColor lightGrayColor];
    self.myLableEat.font = [UIFont systemFontOfSize:16 * WIDTH];
    self.myLableEat.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.myLableEat];
    
    //喜爱人数
    self.myLableEat1 = [[LzwBaseLable alloc]initWithFrame:CGRectMake((375 - 20) / 2 - 50 + 5 * WIDTH, 230 * WIDTH, 60 * WIDTH, 20 * WIDTH)];
    self.myLableEat1.textColor = [UIColor lightGrayColor];
    self.myLableEat1.font = [UIFont systemFontOfSize:16];
    self.myLableEat1.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.myLableEat1];
    
    [_myImageEat release];
    [_myImageEat1 release];
    [_myLableEat release];
    [_myLableEat1 release];

    
}

-(void)setModleEat:(LzwEatModle *)modleEat{
    
    if (_modleEat != modleEat) {
        [_modleEat release];
        _modleEat = [modleEat retain];
    }
    
    self.myLableEat.text = self.modleEat.title;
    self.myLableEat1.text = self.modleEat.likes;
    
    NSURL *url = [NSURL URLWithString:self.modleEat.pic];
    
    [self.myImageEat sd_setImageWithURL:url placeholderImage:nil];
    
}

@end
